Telegram Group & Telegram Channel
141. WAP to multiply and add two complex numbers

Input :
5
-4
4
6

Output :
Sum is 9 + 2i
Product is 44 + 14i

#include<stdio.h>
#include<conio.h>

typedef struct {
int real;
int imag;
} complex;

void getdata (complex *);
void display (complex);
complex sum(complex,complex);
complex mult(complex,complex);

main() {
complex c1,c2,c3,c4;
getdata(&c1);
getdata(&c2);

c3=sum(c1,c2);
printf("Sum is ");
display(c3);

c4=mult(c1,c2);
printf("Product is ");
display(c4);

getch();
}

void getdata(complex *p) {
printf("Enter real ");
scanf("%d",&p->real);
printf("Enter imag ");
scanf("%d",&p->imag);
}

complex sum(complex c1,complex c2) {
complex t;
t.real=c1.real+c2.real;
t.imag=c1.imag+c2.imag;
return t;
}

complex mult(complex c1,complex c2) {
complex t;
t.real=c1.real*c2.real-c1.imag*c2.imag;
t.imag=c1.real*c2.imag+c2.real*c1.imag;
return t;
}

void display {
if(c.imag>=0)
printf("%d+%di\n",c.real,c.imag);
else
printf("%d%di\n",c.real,c.imag);
}
#program_by : @PLAUnit61398



tg-me.com/C_Codings/203
Create:
Last Update:

141. WAP to multiply and add two complex numbers

Input :
5
-4
4
6

Output :
Sum is 9 + 2i
Product is 44 + 14i

#include<stdio.h>
#include<conio.h>

typedef struct {
int real;
int imag;
} complex;

void getdata (complex *);
void display (complex);
complex sum(complex,complex);
complex mult(complex,complex);

main() {
complex c1,c2,c3,c4;
getdata(&c1);
getdata(&c2);

c3=sum(c1,c2);
printf("Sum is ");
display(c3);

c4=mult(c1,c2);
printf("Product is ");
display(c4);

getch();
}

void getdata(complex *p) {
printf("Enter real ");
scanf("%d",&p->real);
printf("Enter imag ");
scanf("%d",&p->imag);
}

complex sum(complex c1,complex c2) {
complex t;
t.real=c1.real+c2.real;
t.imag=c1.imag+c2.imag;
return t;
}

complex mult(complex c1,complex c2) {
complex t;
t.real=c1.real*c2.real-c1.imag*c2.imag;
t.imag=c1.real*c2.imag+c2.real*c1.imag;
return t;
}

void display {
if(c.imag>=0)
printf("%d+%di\n",c.real,c.imag);
else
printf("%d%di\n",c.real,c.imag);
}
#program_by : @PLAUnit61398

BY C Language πŸ‘¨β€πŸ’»


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/C_Codings/203

View MORE
Open in Telegram


C Language ‍ Telegram | DID YOU KNOW?

Date: |

At a time when the Indian stock market is peaking and has rallied immensely compared to global markets, there are companies that have not performed in the last 10 years. These are definitely a minor portion of the market considering there are hundreds of stocks that have turned multibagger since 2020. What went wrong with these stocks? Reasons vary from corporate governance, sectoral weakness, company specific and so on. But the more important question is, are these stocks worth buying?

How to Use Bitcoin?

n the U.S. people generally use Bitcoin as an alternative investment, helping diversify a portfolio apart from stocks and bonds. You can also use Bitcoin to make purchases, but the number of vendors that accept the cryptocurrency is still limited. Big companies that accept Bitcoin include Overstock, AT&T and Twitch. You may also find that some small local retailers or certain websites take Bitcoin, but you’ll have to do some digging. That said, PayPal has announced that it will enable cryptocurrency as a funding source for purchases this year, financing purchases by automatically converting crypto holdings to fiat currency for users. β€œThey have 346 million users and they’re connected to 26 million merchants,” says Spencer Montgomery, founder of Uinta Crypto Consulting. β€œIt’s huge.”

C Language ‍ from sg


Telegram C Language πŸ‘¨β€πŸ’»
FROM USA